package com.qlm.service;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.qlm.entity.Order;

public class ShopMgr {
	public static Record getOrderDetail(String id){
		Order order = Order.Dao.findById(id);
		Record record = order.toRecord();
		Integer addresId = record.getInt("addr_id_");
		Record address = Db.findFirst("select * from t_addr where id = "+addresId);
		record.set("addr", address);
		List<Record> giftList = Db.find("select * from t_order_detail where order_id_ = '"+id+"'");
		for (Record rr : giftList) {
			Integer gift_id = rr.getInt("gift_id_");
			Record gift = Db.findFirst("select * from t_gift where id = "+gift_id);
			rr.set("img_", gift.get("img_"));
			rr.set("name_", gift.get("name_"));
		}
		record.set("gifts", giftList);
		return record;
	}
}
